From a15be40b7c6ede871a2b139192f2db9b46a95ae8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 11 Jul 2018 20:35:40 +0200 Subject: [PATCH] babl: add babl_space_get_icc --- babl/babl-icc.c | 22 ++++++++++++++++++++++ babl/babl-space.h | 2 ++ babl/babl.h | 1 + export-symbols | 1 + 4 files changed, 26 insertions(+) diff --git a/babl/babl-icc.c b/babl/babl-icc.c index 9d520b9..1a445e5 100644 --- a/babl/babl-icc.c +++ b/babl/babl-icc.c @@ -616,6 +616,20 @@ char *babl_space_to_icc (const Babl *babl, } } +const char *babl_space_get_icc (const Babl *babl, int *length) +{ + if (!babl->space.icc_profile) + { + /* overriding constness of babl */ + Babl *babl_noconst = (void*) babl; + babl_noconst->space.icc_profile = babl_space_to_icc (babl, + "babl profile", NULL, 0, + &babl_noconst->space.icc_length); + } + *length = babl->space.icc_length; + return babl->space.icc_profile; +} + typedef uint32_t UTF32; typedef uint16_t UTF16; @@ -851,6 +865,9 @@ babl_icc_make_space (const char *icc_data, trc_red, trc_green, trc_blue); babl_free (state); + ret->space.icc_length = icc_length; + ret->space.icc_profile = malloc (icc_length); + memcpy (ret->space.icc_profile, icc_data, icc_length); return ret; } } @@ -897,6 +914,11 @@ babl_icc_make_space (const char *icc_data, green_x, green_y, blue_x, blue_y, trc_red, trc_green, trc_blue, 1); + + ret->space.icc_length = icc_length; + ret->space.icc_profile = malloc (icc_length); + memcpy (ret->space.icc_profile, icc_data, icc_length); + return ret; } } diff --git a/babl/babl-space.h b/babl/babl-space.h index 488fcd0..119c686 100644 --- a/babl/babl-space.h +++ b/babl/babl-space.h @@ -61,6 +61,8 @@ typedef struct * making it possible to round-trip data. Unless it is sRGB, when * standard should win. */ + char *icc_profile; + int icc_length; } BablSpace; diff --git a/babl/babl.h b/babl/babl.h index 405a06e..164533b 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -525,6 +525,7 @@ void babl_space_get (const Babl *space, const Babl **green_trc, const Babl **blue_trc); +const char *babl_space_get_icc (const Babl *babl, int *length); #ifdef __cplusplus } diff --git a/export-symbols b/export-symbols index df63f41..2b96e83 100644 --- a/export-symbols +++ b/export-symbols @@ -43,6 +43,7 @@ babl_set_user_data babl_space babl_space_from_xyz babl_space_to_icc +babl_space_get_icc babl_chromaticities_make_space babl_space_get babl_space_get_rgbtoxyz -- 2.30.2